<?php
declare (strict_types = 1);

namespace app\api\model\yuql;

use think\Model;

/**
 * @mixin \think\Model
 */
class Wxlogin extends Model
{
    protected $table = '2008a_wxuser';

    /**
     * yuql
     * 查询一整条用户数据
     * @param $data
     * @return Wxlogin|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getUserOne($data){
        $res = Wxlogin::where($data)->find();
        return $res;
    }

    /**
     * yuql
     * 注册入库
     * @param $data
     * @return Wxlogin|Model
     */
    public static function getLogon($data){
        $res = Wxlogin::create($data);
        return $res;
    }

    /**
     * yuql
     * 设置密码时查询用户是否注册成功,是否有此用户
     * @param $params
     * @return Wxlogin|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getPassword($data, $password){
        $res = Wxlogin::where($data)->find();
        $res->password = lock_url($password);
        $res->save();
        return $res;
    }
}
